package com.itheima.string;

import java.util.Scanner;

public class StringMethod01 {
    /*
    键盘录入字符串进行比对是否与已知数据一致,使用equals()方法
     */
    public static void main(String[] args) {
        String userName = "heima001";
        String passWord = "123456";
        Scanner sc = new Scanner(System.in);

        for (int i = 1; i <= 3; i++) {
            System.out.println("请输入用户名:");
            String name = sc.next();
            System.out.println("请输入密码:");
            String pass = sc.next();
            if (userName.equals(name) && passWord.equals(pass)) {
                System.out.println("登录成功");
                break;
            } else {
                if (i == 3) {
                    System.out.println("错误次数过多已被锁定,请明天再试!");
                } else {
                    System.out.println("用户名或密码错误,还有" + (3 - i) + "次机会,请重试!");
                }
            }
        }
    }
}
